package it.appcatalogobase;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class CatalogoOpenHelper extends SQLiteOpenHelper {

    private static final int DATABASE_VERSION = 2;
    public static final String DATABASE_NAME = "Catalogo.db";
    public static final String DICTIONARY_TABLE_NAME_CATEGORIE = "categorie";
    public static final String DICTIONARY_TABLE_NAME_PRODOTTI = "prodotti";
    public static final String DICTIONARY_TABLE_NAME_DOVESIAMO = "dove_siamo";
    public static final String DICTIONARY_TABLE_NAME_CHISIAMO = "chi_siamo";
    public static final String DICTIONARY_TABLE_NAME_DELETE = "delete";
    public static final String DICTIONARY_TABLE_NAME_PR_DETT = "dett_prodotti";
    public static final String COLUMN_ID_DS = "_id";
    public static final String COLUMN_IND_DS = "indirizzo";
    public static final String COLUMN_MAIL_DS = "mail";
    public static final String COLUMN_CELL_DS = "cell";
    public static final String COLUMN_TEL_DS = "tel";
    public static final String COLUMN_FAX_DS = "fax";
    public static final String COLUMN_LAT_DS = "lat";
    public static final String COLUMN_LONG_DS = "long";
    public static final String COLUMN_ID_CS = "_id";
    public static final String COLUMN_DES_CS = "descr";
    public static final String COLUMN_ID_PR = "_id";
    public static final String COLUMN_CAT_PR = "categoria";
    public static final String COLUMN_NAME_PR = "nome";
    public static final String COLUMN_DES_PR = "descrizione";
    public static final String COLUMN_DESH_PR = "descrizione_short";
    public static final String COLUMN_IMG_PR = "immagine";
    public static final String COLUMN_MOD_PR = "data_modifica";
    public static final String COLUMN_COL_PR = "colori";
    public static final String COLUMN_ID_CAT = "_id";
    public static final String COLUMN_NAME_CAT = "nome";
    public static final String COLUMN_DES_CAT = "descrizione";
    public static final String COLUMN_MOD_CAT = "data_modifica";

    private static final String DICTIONARY_TABLE_PRODOTTI_CREATE = "CREATE TABLE " + DICTIONARY_TABLE_NAME_PRODOTTI + " (" + COLUMN_ID_PR + " integer primary key autoincrement, " + COLUMN_NAME_PR + " TEXT, " + COLUMN_DES_PR + " TEXT, " + COLUMN_DESH_PR + " TEXT, "
	    + COLUMN_IMG_PR + " TEXT, " + COLUMN_MOD_PR + " TEXT, " + COLUMN_COL_PR + " TEXT, " + COLUMN_CAT_PR + " TEXT);";

    private static final String DICTIONARY_TABLE_CATEGORIE_CREATE = "CREATE TABLE " + DICTIONARY_TABLE_NAME_CATEGORIE + " (" + COLUMN_ID_CAT + " integer primary key autoincrement, " + COLUMN_NAME_CAT + " TEXT, " + COLUMN_MOD_CAT + " TEXT, " + COLUMN_DES_CAT + " TEXT);";

    private static final String DICTIONARY_TABLE_DOVESIAMO_CREATE = "CREATE TABLE " + DICTIONARY_TABLE_NAME_DOVESIAMO + " (" + COLUMN_ID_DS + " integer primary key autoincrement, " + COLUMN_IND_DS + " TEXT, " + COLUMN_CELL_DS + " TEXT, " + COLUMN_TEL_DS + " TEXT, "
	    + COLUMN_FAX_DS + " TEXT, " + COLUMN_LAT_DS + " TEXT, " + COLUMN_LONG_DS + " TEXT, " + COLUMN_MAIL_DS + " TEXT);";

    private static final String DICTIONARY_TABLE_CHISIAMO_CREATE = "CREATE TABLE " + DICTIONARY_TABLE_NAME_CHISIAMO + " (" + COLUMN_ID_CS + " integer primary key autoincrement, " + COLUMN_DES_CS + " TEXT);";

    // private static final String TEXT_TYPE = " TEXT";
    // private static final String COMMA_SEP = ",";
    /*
     * private static final String SQL_CREATE_ENTRIES = "CREATE TABLE " +
     * FeedEntry.TABLE_NAME + " (" + FeedEntry._ID + " INTEGER PRIMARY KEY," +
     * FeedEntry.COLUMN_NAME_ENTRY_ID + TEXT_TYPE + COMMA_SEP +
     * FeedEntry.COLUMN_NAME_TITLE + TEXT_TYPE + COMMA_SEP + ... // Any other
     * options for the CREATE command " )";
     * 
     * private static final String SQL_DELETE_ENTRIES = "DROP TABLE IF EXISTS "
     * + FeedEntry.TABLE_NAME;
     */

    // public CatalogoOpenHelper(Context context, String name,
    // CursorFactory factory, int version) {
    // super(context, name, factory, version);
    // // TODO Auto-generated constructor stub
    // }

    CatalogoOpenHelper(Context context) {
	super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
	db.execSQL(DICTIONARY_TABLE_PRODOTTI_CREATE);
	db.execSQL(DICTIONARY_TABLE_CATEGORIE_CREATE);
	db.execSQL(DICTIONARY_TABLE_CHISIAMO_CREATE);
	db.execSQL(DICTIONARY_TABLE_DOVESIAMO_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	// TODO Auto-generated method stub
    }
}